package com.vcredit.creditcat.vo.product.h5;

import java.text.ParseException;
import java.util.Comparator;
import java.util.Date;

import com.vcredit.creditcat.util.ConcurrentDateUtil;


public class CallTimeComparator implements Comparator<SubmitPhoneCallInfo>{

	@Override
	public int compare(SubmitPhoneCallInfo o1, SubmitPhoneCallInfo o2) {
		try {
			Date currentDate = null;
			Date formDate = null;
			if(o1.getCalltime().length() == 7) {
				currentDate = ConcurrentDateUtil.parseYMDate(o1.getCalltime());
				formDate = ConcurrentDateUtil.parseYMDate(o2.getCalltime());
			} else if (o1.getCalltime().length() == 19) {
				currentDate = ConcurrentDateUtil.strToDate(o1.getCalltime());
				formDate = ConcurrentDateUtil.strToDate(o2.getCalltime());
			} else {
				return 0;
			}
			
			if(currentDate.before(formDate)) {
				return 1;
			}
			return -1;
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return 0;
	}
}
